import { createStore } from "vuex";

export default createStore({
  state () {
    return {
      loading: false,
      beanPermissions: []
    };
  },
  mutations: {
    setLoading(state) {
      state.loading = true;
    },
    unsetLoading(state) {
      state.loading = false;
    },
    setBeanPermissions(state, beanPermissions) {
      if (!Array.isArray(beanPermissions)) {
        throw new Error("beanPermissions is not an array");
      }
      state.beanPermissions = beanPermissions;
    }
  }
});
